package org.an.demo.test;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.an.demo.R;
import org.an.demo.view.CheckView;
import org.an.ku.base.BaseActivity;

/**
 * 创建时间：2017年01月20日14:54 <br>
 * 作者：fuchaoyang <br>
 * 描述：
 */

public class DrawActivity extends BaseActivity implements View.OnClickListener {

  private CheckView mCheckView;

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_draw);

    mCheckView = (CheckView) findViewById(R.id.check_view);
    findViewById(R.id.btn_check).setOnClickListener(this);
    findViewById(R.id.btn_uncheck).setOnClickListener(this);

    ImageView imageView = (ImageView) findViewById(R.id.imageView);

    String url = "/storage/emulated/0/DCIM/Camera/IMG_20170403_152711.jpg";
    TextView textView = (TextView) findViewById(R.id.textView);
    textView.setText(getShowText("你好我知道", 5));
  }

  private String getShowText(String text, int max) {
    if (text == null) return null;

    if (text.length() > max) {
      return text.substring(0, max - 1) + "...";
    }
    return text;
  }

  @Override public void onClick(View v) {
    String data = "2010-1-2 5:0";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    try {
      Date date = dateFormat.parse(data);
      String format = String.format("%02d:%02d", 5, 0);
    } catch (ParseException e) {
      e.printStackTrace();
    }

    switch (v.getId()) {
      case R.id.btn_check:
        mCheckView.check();
        break;
      case R.id.btn_uncheck:
        mCheckView.unCheck();
        break;
    }
  }
}
